package uml.class_diagram;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;

public class Collec {
	

	public static void main(String[] args) {
		
//		Collec coc = new Collec();
//		coc.linkedListTest();
		
		System.out.println((Long.MAX_VALUE+"").length());

	}
	
	private void hashMapTest(){
		HashMap<Integer, String> hm = new HashMap<Integer, String>();
		
		hm.put(1, "11");
		
		
		
		
	}
	
	private void linkedListTest(){
		LinkedList<Integer> ll = new LinkedList<Integer>();
		ll.add(3);
		ll.add(null);
		ll.add(4);
		ll.getLast();
		ll.getFirst();
		ll.poll();
		
		
		
	}
	
	private void arrayListTest(){
		ArrayList<Integer> al = new ArrayList<Integer>();
		al.add(null);
		al.add(null);
		al.add(null);System.out.println(al.size());
		al.size();
		al.isEmpty();
		al.listIterator();
		al.iterator();
		 ListIterator<Integer> li = al.listIterator();
		 
	}
	
	private void treeSetTest(){
		TreeSet<Integer> ts = new TreeSet<Integer>();
		
		ts.add(1);
		ts.add(2);
		
	}
	
	private void hashSetTest(){
		HashSet<Integer> hs = new HashSet<Integer>();
		hs.add(null);
		System.out.println(hs.size());
		
		hs.clear();
		System.out.println(hs.isEmpty());
	}
	
	private void sortedMapTest(){
		SortedMap<Integer, String> sMap = new TreeMap<Integer, String>();
		
		sMap.put(1, "11");
		sMap.put(2, "22");
		sMap.put(3, "33");
		sMap.put(4, "44");
		sMap.put(5, "55");
		sMap.put(6, "66");
		
		System.out.println(sMap.firstKey());
		System.out.println(sMap.firstKey());
		
		 Set<Integer> ss = sMap.keySet();
		 
		 for (Iterator iterator = ss.iterator(); iterator.hasNext();) {
			System.out.print(sMap.get(iterator.next()));
			System.out.print(";");
			
		}
		System.out.println();
		System.out.println(sMap.headMap(3).size());
		
		
		SortedMap<Integer, String> sm = sMap.tailMap(4);
		
		System.out.println(sm.size());
		
		sm.put(7, "77");
		
		ss = sMap.keySet();
		 
		 for (Iterator iterator = ss.iterator(); iterator.hasNext();) {
			System.out.print(sMap.get(iterator.next()));
			System.out.print(";");
			
		}
		System.out.println();
		sm = sMap.headMap(3);
		System.out.println(sm.size());
		sm.put(0, "00");
		System.out.println(sm.size());
		
		
	}
	
	private void sortedSetTest(){
		SortedSet<Integer> sSet= new TreeSet<Integer>();
		sSet.add(33);
		sSet.add(11);
		sSet.add(44);
		sSet.add(22);
		sSet.add(55);
		sSet.add(66);
		
		Iterator<Integer> it = sSet.iterator();
		while (it.hasNext()) {
			System.out.print(it.next());
			System.out.print(";");
			
		}
		System.out.println();
		int i = 0;
		while (i<6) {
			System.out.print(sSet.first());
			System.out.print(";");
//			sSet.remove(sSet.first());
			i++;
		}
		System.out.println();
		
		SortedSet<Integer> s1= sSet.headSet(44);
		System.out.println(s1.size());
		
		for (Integer hy:s1) {
			System.out.print(hy);
			System.out.print(";");
		}
		System.out.println();
		
		s1 = sSet.tailSet(33);
		System.out.println(s1.size());

		for (Integer hy:s1) {
			System.out.print(hy);
			System.out.print(";");
		}
		System.out.println();
		

		s1 = sSet.subSet(33, 55);
		System.out.println(s1.size());
		
		for (Integer hy:s1) {
			System.out.print(hy);
			System.out.print(";");
		}
		System.out.println();
		
		
	}

	public void setTest() {
		Set<Integer> set = new HashSet<Integer>();

		set.add(1);
		set.add(2);
		set.add(3);
		set.add(4);
		set.add(5);
		set.add(6);

		Iterator<Integer> it = set.iterator();

		while (it.hasNext()) {
			int i = it.next();
			if (i == 3) {
				
				it.remove();
			}
			System.out.println(i);
		}
		it = set.iterator();
		while (it.hasNext()) {
			System.out.println(it.next());
		}
		System.out.println(set.size());
	}

}
